/**
 * Copyright (C) 2010 altuure <altuure [AT] gmail [DOT] com> http://www.altuure.com/projects/yagdao
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.altuure.yagdao.dao;

import com.altuure.yagdao.*;
import com.altuure.yagdao.model.SimpleBean;

import java.util.List;

/**
 * sample dao for test
 * @see SimpleBean
 */
public interface SimpleBeanNewDAO extends GenericDAO<SimpleBean, Long> {

    /***
     * check if old version compatible    
     * @param arg1
     * @return
     */
    @YMethod(type = YMethodType.CRITERIA)
    SearchResultList<SimpleBean> criteria0(@YParameter("pbyte") byte arg1);
    /**
     * Sample criteria builder
     * @param arg1 optional parameter 1
     * @return list of entities
     */
    @YMethod(type = YMethodType.CRITERIA)
    SearchResultList<SimpleBean> criteria1(@YParameter("pint >=") Integer arg1);
   

    @YMethod(type = YMethodType.CRITERIA)
    SearchResultList<Object> criteria1CheckApplied(@YParameter("pint>=20000") boolean apply);

    @YMethod(type = YMethodType.CRITERIA)
    SearchResultList<SimpleBean> criteria2(@YParameter("pint >=") Integer arg1,@YParameter("pint <=") Integer arg2);

    @YMethod(type = YMethodType.CRITERIA)
    SearchResultList<SimpleBean> criteria3(@YParameter("pstring is null") boolean apply);
    
    
    @YMethod(type = YMethodType.CRITERIA)
    SearchResultList<Object> criteria2CheckApplied(@YParameter("pint>=20000") boolean apply1,@YParameter( "pint<=50000") boolean apply2);

    @YMethod(type = YMethodType.CRITERIA,where="pint>=20000 and pint<=50000" )
    SearchResultList<Object> criteriaWhereAnd();
    @YMethod(type = YMethodType.CRITERIA,where="pint>=50000 OR pint<=30000" )
    SearchResultList<Object> criteriaWhereOr();

    
    @YMethod(type = YMethodType.CRITERIA)
    SearchResultList<SimpleBean> criteria3(@YParameter("? <=pint") Integer arg1);

    @YMethod(type = YMethodType.CRITERIA,
                groupBy="pbyte",
                select="count(id),pbyte")
    List<Object[]> criteriaGroup1();

    @YMethod(type = YMethodType.CRITERIA,
            groupBy="pbyte",
            select="count(id),pbyte,sum(pint)",
            having="count(id)>9")
            List<Object[]> criteriaGroupHaving();

    @YMethod(type = YMethodType.CRITERIA,
            select="id,year(pdate),month(pdate),day(pdate),hour(pdate),minute(pdate),second(pdate),currenttime(),currenttimestamp(),currentdate()"
                ,where="id=2")
    List<Object[]> criteriaDateFunctions();    
    
    @YMethod(type = YMethodType.CRITERIA,
            groupBy="month(pdate)",
            select="count(id),month(pdate)")
    List<Object[]> criteriaGroup2();

    /*@YMethod(type = YMethodType.CRITERIA)
    SearchResultList<SimpleBean> criteria1(@YParameter(value = "pint", operator = YOperator.GE) Integer arg1, YPage page);

    @YMethod(type = YMethodType.CRITERIA, select = "pint")
    SearchResultList<Object> criteriaSelected1(@YParameter(value = "pint", operator = YOperator.GE) Integer arg1);


    @YMethod(type = YMethodType.CRITERIA, select =  "pint,pdate" )
    SearchResultList<Object[]> criteriaSelected2(@YParameter(value = "pint", operator = YOperator.GE) Integer arg1);

    @YMethod(type = YMethodType.CRITERIA)
    SearchResultList<SimpleBean> criteria2(@YParameter(value = "pint", operator = YOperator.GE) Integer arg1,
            @YParameter(value = "pdate", operator = YOperator.LE) Date arg2

    );

    @YMethod(type = YMethodType.CRITERIA)
    SearchResultList<SimpleBean> criteria2(@YParameter(value = "pint", operator = YOperator.GE) Integer arg1,
            @YParameter(value = "pdate", operator = YOperator.LE) Date arg2, YPage page);

    @YMethod(type = YMethodType.CRITERIA)
    SearchResultList<SimpleBean> criteriaBetween(@YParameter(value = "pint", operator = YOperator.BETWEEN) Integer[] arg);

    @YMethod(type = YMethodType.CRITERIA)
    SearchResultList<SimpleBean> criteriaIn(@YParameter(value = "pint", operator = YOperator.IN) Integer[] arg);

    @YMethod(type = YMethodType.CRITERIA)
    SearchResultList<SimpleBean> criteriaEqual(@YParameter(value = "pbyte", operator = YOperator.EQUAL) byte arg);

    @YMethod(type = YMethodType.CRITERIA)
    SearchResultList<SimpleBean> criteriaNotEqual(
            @YParameter(value = "pbyte", operator = YOperator.EQUAL, not = true) byte arg);

    @YMethod(type = YMethodType.CRITERIA)
    SearchResultList<SimpleBean> criteriaLE(@YParameter(value = "pint", operator = YOperator.LE) Integer arg);

    @YMethod(type = YMethodType.CRITERIA)
    List<SimpleBean> criteriaLTList(@YParameter(value = "pint", operator = YOperator.LT) Integer arg);

    @YMethod(type = YMethodType.CRITERIA)
    SearchResultList<SimpleBean> criteriaLT(@YParameter(value = "pint", operator = YOperator.LT) Integer arg);

    @YMethod(type = YMethodType.CRITERIA)
    SearchResultList<SimpleBean> criteriaGELT(@YParameter(value = "pint", operator = YOperator.GE) Integer min,
            @YParameter(value = "pint", operator = YOperator.LT) Integer maxE);

    @YMethod(type = YMethodType.CRITERIA)
    SearchResultList<SimpleBean> criteriaGT(@YParameter(value = "pint", operator = YOperator.GT) Integer arg);

    @YMethod(type = YMethodType.CRITERIA)
    SearchResultList<SimpleBean> criteriaGE(@YParameter(value = "pint", operator = YOperator.GE) Integer arg);

    @YMethod(type = YMethodType.CRITERIA)
    SearchResultList<SimpleBean> criteriaULike(@YParameter(value = "pstring", operator = YOperator.ULIKE) String arg);

    @YMethod(type = YMethodType.CRITERIA)
    SearchResultList<SimpleBean> criteriaLike(@YParameter(value = "pstring", operator = YOperator.LIKE) String arg);

    @YMethod(type = YMethodType.CRITERIA, orderBy = "pint desc")
    SearchResultList<SimpleBean> preDefinedOrder1(@YParameter(value = "pbyte", operator = YOperator.EQUAL) byte arg);

    @YMethod(type = YMethodType.CRITERIA, orderBy = "pint asc")
    SearchResultList<SimpleBean> preDefinedOrder2(@YParameter(value = "pbyte", operator = YOperator.EQUAL) byte arg,
            YLimit limits);

    @YMethod(type = YMethodType.CRITERIA, orderBy = "pint desc")
    SearchResultList<SimpleBean> preDefinedOrder3(@YParameter(value = "pbyte", operator = YOperator.EQUAL) byte arg,
            YPage page);

    @YMethod(type = YMethodType.COUNT)
    long count1(@YParameter(value = "pint", operator = YOperator.GE) Integer arg1);

    @YMethod(type = YMethodType.COUNT)
    long count2(@YParameter(value = "pint", operator = YOperator.GE) Integer arg1,
            @YParameter(value = "pdate", operator = YOperator.LE) Date arg2);

    @YMethod(type = YMethodType.EXECUTE,query = "update SimpleBean set pint=:newInt where id=:id ")
    int execute1(@YParameter(value = "newInt") int newInt,@YParameter(value = "id") long id);
     */
}
